package com.fesine.config;

import com.alibaba.dubbo.config.spring.ReferenceBean;
import com.dap.batch.service.IBatchGroupService;
import com.dap.batch.service.IBatchJobService;
import com.dap.batch.service.IBatchSchedulerBroker;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @description: 类描述
 * @author: Fesine
 * @createTime:2017/9/14 23:07
 * @update:修改内容
 * @author: Fesine
 * @updateTime:2017/9/14 23:07
 */
@Configuration
public class ReferConfig extends DubboBaseConfig {

    //@Bean
    public ReferenceBean<IBatchGroupService> groupService(){
        ReferenceBean<IBatchGroupService> ref = new ReferenceBean<>();
        ref.setInterface(IBatchGroupService.class);
        this.initRef(ref);
        return ref;
    }
    //@Bean
    public ReferenceBean<IBatchJobService> jobService(){
        ReferenceBean<IBatchJobService> ref = new ReferenceBean<>();
        ref.setInterface(IBatchJobService.class);
        this.initRef(ref);
        return ref;
    }
    @Bean
    public ReferenceBean<IBatchSchedulerBroker> schedulerBroker(){
        ReferenceBean<IBatchSchedulerBroker> ref = new ReferenceBean<>();
        ref.setInterface(IBatchSchedulerBroker.class);
        this.initRef(ref);
        return ref;
    }

    private void initRef(ReferenceBean ref){
        ref.setTimeout(5000);
        ref.setRetries(3);
        ref.setCheck(false);
    }



}
